home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7444 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  44 lines

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: tycope@aol.com (Tycope)
  3. Newsgroups: comp.lang.c
  4. Subject: Simple Program Question
  5. Date: 26 Feb 1996 12:40:14 -0500
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4gsr9u$sk6@newsbf02.news.aol.com>
  9. Reply-To: tycope@aol.com (Tycope)
  10. NNTP-Posting-Host: newsbf02.mail.aol.com
  11.  
  12. I am trying to write a non -interactive program that calculates all
  13. integer triples (i, j, k) such that 
  14. 0 < i < j < k < l and i + j + k = l. Print out the number of triples that
  15. satisfy the requirements and print out every millionth triple.  Can anyone
  16. see where I am missing the boat in the following code.  The program runs
  17. and immediately terminates.  Thanks in advance for any feedback. 
  18.  
  19. #include <stdio.h>
  20.  
  21. long int i, j, k, l;
  22. long int count;
  23.  
  24. int
  25. main (void)
  26. {
  27.     do
  28.     {
  29.         (l = i + j + k);
  30.         (i = 1);
  31.         (j = 2);
  32.         (k = 3);
  33.         (i++, j++, k++);
  34.         (++count);
  35.     if (count % 1000000 == 0)
  36.      {
  37.         printf("%ld(i) + %ld(j) + %ld(k) = %ld(l)", i, j, k, l);
  38.      }
  39.  
  40.     } while (0 < i < j < k < l);
  41.  
  42.     return (0);
  43. }
  44.